Kerry Back
from alpaca.data import StockHistoricalDataClient
from alpaca.data.requests import StockLatestQuoteRequest
data_client = StockHistoricalDataClient(KEY, SECRET_KEY)
params = StockLatestQuoteRequest(
symbol_or_symbols=df.index.to_list()
)
quotes = data_client.get_stock_latest_quote(params)
df["ask"] = {x: quotes[x].ask_price for x in quotes}
df["bid"] = {x: quotes[x].bid_price for x in quotes}positions = trading_client.get_all_positions() if len(positions) > 0: positions = {x.symbol: int(x.qty) for x in positions} positions = pd.Series(positions) df[“current”] = positions df[“current”] = df.current.fillna(0) else: df[“current”] = 0
Equal weight top 100 longs and equal weight bot